package com.winspread.app.ui

import android.os.Build
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.RequiresApi
import com.winspread.app.R
import com.winspread.app.databinding.ActivityToastBinding
import com.winspread.mvvm.base.vm.BaseNotVmActivity
import com.winspread.ui.toast.CustomToast

/**
 *Author: Amin
 *Data: 2021/10/9 14:45
 *
 *Description:
 *
 */
class ToastActivity : BaseNotVmActivity<ActivityToastBinding>(R.layout.activity_toast) {

    @RequiresApi(Build.VERSION_CODES.M)
    override fun initView() {
        binding.tvToastSuccess.setOnClickListener {
            CustomToast.Builder(application).setContentView(R.layout.toast_content_view).setToastViewLins {
                it?.setBackgroundResource(R.drawable.toast_success_bg)
                it?.findViewById<ImageView>(R.id.toast_icon)?.setImageResource(R.mipmap.toast_success)
                (it?.findViewById<TextView>(R.id.toast_msg))?.text = "你好,成功了！"
            }.build().showShort()
        }


        binding.tvToastError.setOnClickListener {
            CustomToast.Builder(application).setContentView(R.layout.toast_content_view).setToastViewLins {
                it?.setBackgroundResource(R.drawable.toast_error_bg)
                it?.findViewById<ImageView>(R.id.toast_icon)?.setImageResource(R.mipmap.toast_error)
                (it?.findViewById<TextView>(R.id.toast_msg))?.text = "你好,失败了！"
            }.build().showShort()
        }

        binding.tvToastMsg.setOnClickListener {
            CustomToast.Builder(application).setContentView(R.layout.toast_content_view).setToastViewLins {
                it?.setBackgroundResource(R.drawable.toast_success_bg)
                it?.findViewById<ImageView>(R.id.toast_icon)?.visibility = View.GONE
                (it?.findViewById<TextView>(R.id.toast_msg))?.text = "Toast提示"
            }.build().showShortSafe()

        }


    }

}